import bpy

from ..operators.AddonOperators import StaticButtonOperator, BlenderMCPOperatorStop
from ..operators.AddonOperators import BlenderMCPOperatorStart
from ....common.types.framework import reg_order


class BasePanel(object):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "ExampleAddon"

    @classmethod
    def poll(cls, context: bpy.types.Context):
        return True


# This panel will be drawn after ExampleAddonPanel since it has a higher order value
@reg_order(0)
class ExampleAddonPanel2(BasePanel, bpy.types.Panel):
    bl_label = "Example Addon Side Bar Panel"
    bl_idname = "SCENE_PT_sample2"

    def draw(self, context: bpy.types.Context):
        layout = self.layout
        layout.label(text="BlenderMCP Panel")
        # 当前只是为了测试常驻按钮的点击测试-点击对图形缩小0.8
        layout.operator(StaticButtonOperator.bl_idname)
        # 测试服务器的装
        scene = context.scene
        if not scene.blender_mcp_server_running:
            layout.operator(BlenderMCPOperatorStart.bl_idname)
            print("Start MCP Server")
        else:
            layout.operator(BlenderMCPOperatorStop.bl_idname)
            print("Stop MCP Server")
